<?php 
/**
 * $Id: default.php 4 2010-10-07 14:41:28Z ahmtsari $
 * Bid view for BF Auction Component
 *
 * @package    Joomla
 * @subpackage Components
 * @link http://www.tamlyncreative.com.au/software
 * @copyright	Copyright (c) 2010 - Tamlyn Creative Pty Ltd.
 * @license		GNU GPL
 *
 *	  BF Auction is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    BF Auction is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with BF Auction.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * Author's notes: When GNU speaks of free software, it is referring to freedom, not price.
 * We encourage you to purchase your copy of BF Auction from the developer (Tamlyn Creative Pty Ltd),
 * so that we can continue to make this product better and continue to provide a high quality of support.
 *
 */

// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die();

?>
<?php
// For popup help
JHTML::_('behavior.tooltip');

$user =& JFactory::getUser();

    $Itemid = JRequest::getVar('Itemid');
	$menu =& JMenu::getInstance('site');
	$config = & $menu->getParams( $Itemid );
	
	$currency = $config->get( 'currency' );
	$bidIncrement = $config->get( 'bidIncrement' );
	$dst_fix = $config->get( 'dst' );
	
// is dst on on that particular date ?
  if (is_numeric( $date)) {
    $ts = $date;
  } else {
    $ts = strtotime( $date . ' UTC');
  }
  $dst = date( 'I', $ts);

$now =& JFactory::getDate();
if($dst_fix){
	$now->setOffset($user->getParam('timezone')+$dst);
}else{
	$now->setOffset($user->getParam('timezone'));
}
$currentDate=$now->toFormat();
$endDate = $this->bfauction->endDate;

if($currentDate > $endDate){
   JError::raiseWarning( 500, 'This auction has ended' );
}
  
if($user->id == 0){
	JError::raiseWarning( 500, 'You must log in before you can bid!' );
}
?>

<div class="col width-65">
	<fieldset class="adminform">
		<legend><?php echo JText::_( 'Item Details' ); ?></legend>
		
		<table width="100%">
		<tr>
		<td>
		
		<i>You are about to bid on the following item:</i><br>
		<br>

		<table class="admintable">
		<tr>
			<td valign="top" align="right" class="key">
				<label for="title">
					<?php echo JText::_( 'Title' ); ?>: 
				</label>
			</td>
			<td>
			   <?php echo $this->bfauction->title; ?>
			</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="itemid">
					<?php echo JText::_( 'Item id' ); ?>:
				</label>
			</td>
			<td>
			   <?php echo $this->bfauction->id; ?>
			</td>
		</tr>

		<tr>
			<td width="100" align="right" class="key">
				<label for="Bid">
					<?php echo JText::_( 'Current Bid' ); ?>:
				</label>
			</td>
			<td>
			    <strong><?php echo $currency; ?><?php echo $this->bfauction->currentBid;?></strong>
			</td>
		</tr>
		<tr>
		<td>
		   &nbsp;
		</td>
		<td>
		   <i><?php echo JText::_( 'Please note this page does not refresh so it is possible someone else is bidding on this item while you view this page.' ); ?></i><br>
		</td>
		</tr>
		<tr>
			<td width="100" align="right" class="key">
				<label for="EndDate">
					<?php echo JText::_( 'End Date' ); ?>:
				</label>
			</td>
			<td>
			    <strong><?php echo $endDate;?></strong>
			</td>
		</tr>		

<?php 
if($user->id != 0){
?>
		<tr>
			<td width="100" align="right" class="key">
				<label for="User id">
					<?php echo JText::_( 'Your Name' ); ?>:
				</label>
			</td>
			<td>
				<?php
				echo $user->name;
				?>		    
			</td>
		</tr>
		
		<?php if($currentDate < $endDate){ ?>
		<tr>
			<td width="100" align="right" class="key">
				<label for="Bid">
					<?php echo JText::_( 'Your Bid' ); ?>:
				</label>
			</td>
			<td>
			    <form method="post" name="adminForm">
			    <strong><?php echo $currency; ?></strong>&nbsp;<input class="inputbox" type="text" name="bid" id="bid" size="5" value="<?php echo $this->bfauction->currentBid+(int)$bidIncrement; ?>"/>
				<input type="hidden" name="option" value="com_bfauction" />
				<input type="hidden" name="task" value="mybid" />
				<input type="hidden" name="boxchecked" value="0" />
				<input type="hidden" name="controller" value="" />
				<input type="hidden" name="cid" value="<?php echo $this->bfauction->id; ?>" />
				<?php echo JHTML::_( 'form.token' ); ?>
				<input name="Submit" type="submit" id="Submit" value="<?php echo JText::_( 'Bid now' ); ?>" />
				</form>
			</td>
		</tr>
		<tr>
			<td>
				&nbsp;
			</td>
			<td>
				<i><?php echo JText::_( 'Minimum bid increment is' ); ?>&nbsp;<strong><?php echo $currency; ?><?php echo $bidIncrement; ?></strong></i>
			</td>
		</tr>
		<?php } ?>
		<tr>
			<td>
				&nbsp;
			</td>
			<td>
				<a href="index.php?option=com_bfauction&task=bidHistory&cid=<?php echo $this->bfauction->id; ?>" target="_blank"><?php echo JText::_( 'Bid History' ); ?></a>
			</td>
		</tr>
		
<?php 
} //end if
?>

	</table>
	
	</td>
	<td>
    	<a href="<?php echo $this->bfauction->image;?>" target="_blank"><img src="<?php echo $this->bfauction->image;?>" width="200" border=0></a>
    </td>
    </tr>
    </table>
    <br>
     <?php echo $this->bfauction->description; ?>

	<input class="inputbox" type="hidden" name="ordering" id="ordering" size="6" value="<?php echo $this->bfbid->ordering;?>" />

	</fieldset>
</div>
<div class="col width-35">
	&nbsp;
</div>
<div class="clr"></div>

<!-- don't remove the following 7 lines if you didn't purchase BF Auction. Purchased version BF Auction Pro has no restrictions. -->
	<br>
	<table width="100%">
	<tr>
	<td><?php echo JText::_('Powered by'); ?> <a href="http://www.tamlyncreative.com.au/software/" target="_blank">BF Auction</a></td>
	<td><a href="http://www.tamlyncreative.com.au/software/" target="_blank"><img src="./components/com_bfauction/images/bftick.jpg" height="42" align="right" border="0" ></a></td>
	</tr>
	</table>
